<?php
	class api extends common{
		// private $table_api = 'mobile_api';

		
		/**
		 * 获得接口信息
		 * @param int 		$id  接口ID
		 * @param string 	$key 查询内容
		 * @return result
		 */
		/*function mobile_api($id="1", $key='*'){
			if($id!='' && $id!=null){
				$sql=$this->table_api." WHERE id='".$id."'";
				$res = $this->getInfo($sql,$key);
			}
			return $res;
		}*/


		/**
		 * 发送短信
		 * @param string 	$mobile  手机号码
		 * @param string 	$key 	 发送内容
		 * @return result
		 */
		function send($mobile,$data){
			//1.读取帐号密码
			// $api=$this->mobile_api();
			// $account=$api['account']; //帐号
			// $pswd=$api['pswd']; 	//密码
			$account='VIP_sdck'; //帐号
			$pswd='Tch123456'; 	//密码

			if(!empty($mobile) && !empty($data)){
				//2.发送短信
				$post_data = array();
				$post_data['account'] = iconv('GB2312', 'GB2312',"$account");
				$post_data['pswd'] = iconv('GB2312', 'GB2312',"$pswd");
				$post_data['mobile'] =$mobile;
				$post_data['msg']=mb_convert_encoding("$data",'UTF-8', 'auto');
				$post_data['needstatus']=false;

				$url='http://222.73.117.158/msg/HttpBatchSendSM?'; 
				$o="";
				foreach ($post_data as $k=>$v){
				   $o.= "$k=".urlencode($v)."&";
				}
				$post_data=substr($o,0,-1);
				 
				$ch = curl_init();
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_HEADER, 0);
				curl_setopt($ch, CURLOPT_URL,$url);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
				curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
				$result = curl_exec($ch);
			}
			
			return $result;
		}
		
		
	
	}